import { http } from '../http';
import {
	CommonWordsLibType,
	CommonWordType,
	PhrasesType,
	GetCommonWordsSortByTypeQueryType,
	GetCommonWordsSortByTypeResponseType,
	AddOrUpdateLibCommonSlangTypeParams,
	AddOrUpdatePhrasesParams
} from './lib.type';

const baseUrl = '/api/aias/lib';

/**
 * 获取通用词库列表
 * @param params - GetCommonWordsSortByTypeQueryType
 * @returns Promise<GetCommonWordsSortByTypeResponseType>
 */
export const getLibCommonSlangSortByTypeAPI = (
	params: GetCommonWordsSortByTypeQueryType
): Promise<GetCommonWordsSortByTypeResponseType> => {
	return http.get(
		`${baseUrl}/getLibCommonSlangSortByType?searchValue=${params.searchValue}&pageNum=${params.pageNum}&pageSize=${params.pageSize}`
	);
};

/**
 * 删除通用词库数据
 * @param ids string
 * @returns  Promise<void>
 */
export const delLibCommonSlangTypeAPI = (ids: string): Promise<void> => {
	return http.get(`${baseUrl}/delLibCommonSlangType?ids=${ids}`);
};

/**
 * 添加通用词库数据类型
 */
export const addLibCommonSlangTypeAPI = (
	params: AddOrUpdateLibCommonSlangTypeParams
): Promise<CommonWordType[]> => {
	return http.post(`${baseUrl}/addLibCommonSlangType`, params);
};

/**
 * 添加常用语
 */
export const addLibCommonSlangAPI = (params: AddOrUpdatePhrasesParams): Promise<PhrasesType[]> => {
	return http.post(`${baseUrl}/addLibCommonSlang`, params);
};

/**
 * 获取常用语列表
 */
export const getLibCommonSlangAPI = (typeId: number): Promise<PhrasesType[]> => {
	return http.get(`${baseUrl}/getLibCommonSlang?typeId=${typeId}`);
};

/**
 * 删除常用语
 */
export const delLibCommonSlangAPI = (ids: string): Promise<void> => {
	return http.get(`${baseUrl}/delLibCommonSlang?ids=${ids}`);
};
